#include "Application.h"
#include "MainWindow.h"

#include "IE\Definitions.h"

#include "IE\IE.h"
#include "IE\Scene.h"

#include "Scripts\Blockade.h"

#include <assert.h>

static wchar_t const *g_szGameFile;

class CCustomCommandLineInfo : public CCommandLineInfo
{
	virtual void ParseParam( TCHAR const *_szParam, BOOL _bFlag, BOOL _bLast )
	{
		g_szGameFile = _szParam;
	}
};

CApplication g_Application;

// engine
IE::CScene *g_pScene;

CApplication::CApplication()
{
}

CApplication::~CApplication()
{
}

BOOL CApplication::InitInstance()
{
	// parse the command line info
	CCustomCommandLineInfo cmd;
	ParseCommandLine(cmd);

	//// create the game window
	//CMainWindow* pWindow = new CMainWindow;
	//pWindow->Create(NULL, L"Blockade");
	//pWindow->ShowWindow(SW_SHOWNORMAL);
	//m_pMainWnd = pWindow;

	// TODO: 'viewport' somehow this word gets the game into the window

	//// start up the engine
	//IE::Initialize(*pWindow);

	//// create a scene
	//g_pScene = IE::CreateScene();

	//// add a camera to the scene
	//g_pCamera = IE::CreateCamera();
	//g_pCamera->SetType(IE::CAMERATYPE_PERSPECTIVE);
	//g_pCamera->SetMode(IE::CAMERAMODE_STATIC);

	//matrix_t matTarget = matrix_t::CreateIdentity();
	//g_pCamera->SetTarget(matTarget);



	//g_pScene->Initialize();
	//g_pScene->AddScriptState( new CBlockade(g_pScene) );


	//g_pScene->AddViewport()

	// success
	return TRUE;
}

int CApplication::ExitInstance()
{
	//g_pScene->Shutdown();
	//delete g_pScene;
	//g_pScene = CE_NULL;

	// TODO: unload stuff

	// TODO: 'viewport' destruction

	//// shut down the engine
	//IE::Shutdown();

	//// destroy the game window
	//delete m_pMainWnd;
	//m_pMainWnd = NULL;

	// success
	return 0;
}
